//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<SplashScreen.h>
///	@path	~/src/appear/ui/
///	@date	2007/07/03
///	@desc	Splash screen base class.

#pragma once

#include "xeres.h"

namespace xeres {

	/*!
		\class	SplashScreen
		\brief	Encapsulate a simple splash screen class,
				which only manipulate a created window instance
				to match behavior of showing loading info.
				While displaying splash screen, processing
				should be running on background thread, in order
				to keep foreground window responsible.
	*/
	class SplashScreen
	{
	public:

		/// \ctor
		SplashScreen( void );

		/// \dtor
		virtual ~SplashScreen( void );

	//@ manipulation

		/*!
			\brief		Call this method to active splash sceen.
						It will call other interface function to
						set correct window and draw the screen.
			\param[in]	hScreenWnd	Window handle of splash screen.
			\param[in]	width		Window width.
			\param[in]	height		Window height.
		*/
		void ShowLoading( HWND hScreenWnd , int width , int height );

		/*!
			\brief		Call to close splash screen.
		*/
		void Close( void );

		/*!
			\brief		Set splash screen title.
			\param[in]	title	Screen title text.
		*/
		void SetTitle( const WString& title );

		/*!
			\brief		Set splash screen cue info.
			\param[in]	cue		Screen cue text.
		*/
		void SetCue( const WString& cue );

		/*!
			\brief		Set splash screen progress.
			\param[in]	progress	Loading progress, 0~100.
		*/
		void SetProgress( int progress );


	//@ local

		/*!
			\brief		Get window handle.
			\return		Splash screen window handle.
		*/
		HWND GetWindow( void ) const { return m_hWnd; }

		/*!
			\brief		Get title text.
			\return		The title text.
		*/
		WString GetTitle( void ) const { return m_title; }

		/*!
			\brief		Get cue info text.
			\return		The cue text.
		*/
		WString GetCue( void ) const { return m_cue; }

		/*!
			\brief		Get progress.
			\return		Progress percent num, 0~100.
		*/
		int GetProgress( void ) const { return m_progress; }


	//@ interface

		/*!
			\brief		Call while preparing to show window.
						To setup some drawing context or
						prepare some resources.
		*/
		virtual void OnPrepare( void ) = 0;

		/*!
			\brief		Draw screen function.
		*/
		virtual void OnDraw( void ) = 0;

		/*!
			\brief		Call before closing the window.
		*/
		virtual void OnClose( void ) = 0;


	private:

	//@ data

		HWND			m_hWnd;
		int				m_progress;
		WString			m_title;
		WString			m_cue;
	};

	/*!
		\class	DefaultSplashScreen
		\brief	This class implement a splash screen,
				which draws only xeres's info , 
				cue text & loading progress.
	*/
	class DefaultSplashScreen : public SplashScreen
	{
	public:

		/// \ctor
		DefaultSplashScreen( void );

	//@ interface

		/*!
			\brief		Call while preparing to show window.
						To setup some drawing context or
						prepare some resources.
		*/
		virtual void OnPrepare( void );

		/*!
			\brief		Draw screen function.
		*/
		virtual void OnDraw( void );

		/*!
			\brief		Call before closing the window.
		*/
		virtual void OnClose( void );

	private:

	//@ data
		HBRUSH		m_backgroundBrush;
		HBRUSH		m_loadingBrush;
		HBRUSH		m_loadingBackground;
		HFONT		m_textFont;
		HFONT		m_cueFont;		
	};

} // namespace xeres
